# -*- coding: utf8 -*-
'''
    1.4.1 图像模糊
'''

from PIL import Image
from pylab import array, figure, gray, subplot, imshow, title, axis, show, zeros, np
from scipy.ndimage import filters

infile = 'img/haizei.jpg'

im = array(Image.open(infile).convert('L'))

figure()
gray()
subplot(1, 4, 1)

imshow(im)
title('Ploting: "Haizei.jpg"')
# 隐藏坐标轴
axis('off')

for bi, blur in enumerate([2, 5, 10]):
    im2 = zeros(im.shape)
    im2 = filters.gaussian_filter(im, blur)
    im2 = np.uint8(im2)
    imNum = str(blur)
    subplot(1, 4, 2 + bi)
    title('Ploting' + imNum)
    axis('off')
    imshow(im2)

show()
